package com.hx.yupao.once;

import com.hx.yupao.mapper.UserMapper;
import com.hx.yupao.model.domain.User;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;

import javax.annotation.Resource;

@Component
public class InsertUsers {
    @Resource
    private UserMapper userMapper;

    /**
     * 批量插入用户
     */
//    @Scheduled(fixedDelay = 5000, fixedRate = Long.MAX_VALUE)
    public void doInsertUsers() {
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        final int INSERT_NUM = 1000;

        for (int i = 0; i < INSERT_NUM; i++) {
            User user = new User();
            user.setUsername("假鱼皮");
            user.setUserAccount("fakeyupi");
            user.setEmail("123@qq.com");
            user.setPhone("12345678");
            user.setAvatarUrl("https://ecmb.bdimg.com/tam-ogel/-1901234115_-74484459_88_88.png");
            user.setGender(0);
            user.setUserRole(0);
            user.setPlanetCode("11111");
            user.setTags("[]");

        }
        stopWatch.stop();
        System.out.println(stopWatch.getTotalTimeMillis());
    }
}
